{include file='_header'}
<script type="text/javascript" src="__STATIC__/js/lib/moment.js"></script>
<link rel="stylesheet" href="__STATIC__/components/datetimepicker/jquery.datetimepicker.css">
<link rel="stylesheet" href="__STATIC__/components/daterangepicker/daterangepicker.css">
<style type="text/css">
    .pd0{padding:0;}
    .trhead td {  background:#efefef;text-align: center}
    .trbody td {  text-align: center; vertical-align:top;border-left:1px solid #f2f2f2;overflow: hidden; font-size:12px;}
    .trorder { background:#f8f8f8;border:1px solid #f2f2f2;text-align:left;}
    .ops { border-right:1px solid #f2f2f2; text-align: center;}
</style>
<div class="page-header">
    当前位置：<span class="text-primary">订单管理</span>
</div>
<div class="page-content">
<div class="main">
    <form action="" method="get" class="form-horizontal table-search" role="form">
        <input type="hidden" name="status"  value="{$status}" />
        <input type="hidden" name="verify"  value="{$verify}" />
        <div class="page-toolbar m-b-sm m-t-sm">
            <div class="col-sm-6">
                <div class="btn-group btn-group-sm" style='float:left'>
                    {:tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $starttime),'endtime'=>date('Y-m-d H:i', $endtime)),true);}
                </div>
            </div>
            <div class="col-sm-6 pull-right">
                <div class="input-group">
                    <div class="input-group-select">
                        <select name="paytype" class="form-control input-sm select-md" style="width:100px;">
                            <option value="" {if $paytype==''}selected{/if}>支付方式</option>
                            {foreach name='paytype' key='key' item='type'}
                            <option value="{$key}" {if $paytype == "$key"} selected="selected" {/if}>{$type}</option>
                            {/foreach}
                        </select>
                    </div>
                    <div class="input-group-select">
                        <select name='searchtime' class='form-control  input-sm select-md' style="width:100px;"  >
                            <option value=''>不按时间</option>
                            <option value='create' {if $searchtime=='create'}selected{/if}>下单时间</option>
                            <option value='pay' {if $searchtime=='pay'}selected{/if}>付款时间</option>
                            <option value='send' {if $searchtime=='send'}selected{/if}>发货时间</option>
                            <option value='finish' {if $searchtime=='finish'}selected{/if}>完成时间</option>
                        </select>
                    </div>
                    <div class="input-group-select">
                        <select name='searchfield'  class='form-control  input-sm select-md' style="width:100px;"  >
                            <option value='orderno' {if $searchfield=='orderno'}selected{/if}>订单号</option>
                            <option value='member' {if $searchfield=='member'}selected{/if}>会员信息</option>
                            <option value='goodstitle' {if $searchfield=='goodstitle'}selected{/if}>商品名称</option>
                            <option value='goodssn' {if $searchfield=='goodssn'}selected{/if}>商品编码</option>
                            <option value='saler' {if $searchfield=='saler'}selected{/if}>核销员</option>
                            <option value='store' {if $searchfield=='store'}selected{/if}>核销门店</option>
                        </select>
                    </div>
                    <input type="text" class="form-control input-sm"  name="keyword" value="{$keyword}" placeholder="请输入关键词"/>
                    <span class="input-group-btn">
                        <button class="btn btn-sm btn-primary" type="submit"> 搜索</button>
                        <button type="submit" name="export" value="1" class="btn btn-success btn-sm">导出</button>
                    </span>
                </div>
            </div>
        </div>
    </form>
    {if count($list)>0}
    <table class='table table-responsive' style='table-layout: fixed;'>
        <tr style='background:#f8f8f8'>
            <td style='width:60px;border-left:1px solid #f2f2f2;'>商品</td>
            <td style='width:150px;'></td>
            <td style='width:70px;text-align: right;;'>单价/数量</td>
            <td  style='width:100px;text-align: center;'>买家</td>
            <td style='width:100px;text-align: center;'>支付/配送/退款</td>
            <td style='width:100px;text-align: center;'>金额</td>
            <td style='width:100px;text-align: center;'>操作</td>
            <td style='width:90px;text-align: center'>状态</td>
        </tr>
        {foreach name='list' item='item'}
        <tr ><td colspan='8' style='height:20px;padding:0;border-top:none;'>&nbsp;</td></tr>
        <tr class='trorder'>
            <td colspan='4' >
               <span style="font-weight: bold"> {:date('Y-m-d',$item['createtime'])} {:date('H:i:s',$item['createtime'])}</span>
                订单编号:  {$item['orderno']}
            </td>
            <td colspan='4' style='text-align:right;font-size:12px;' class='aops'>
                {if !empty($item['remark'])}
                <i class="icow icow-flag-o" style="color: #df5254;display: inline-block;vertical-align: middle" title="  "></i>
                备注
                {else}
                <i class="icow icow-yibiaoji" style="color: #999;display: inline-block;vertical-align: middle" title=" " ></i>
                备注
                {/if}
                {if $item['status'] == 0 }
                <a class='op'  data-toggle='ajaxModal' href="{:url('admin/groups/orderclose',array('id'=>$item['id']))}" >

                    <i class="icow icow-shutDown" title=""  style="color: #999;margin-right: 3px;display: inline-block;vertical-align: middle"></i>关闭订单</a>

                {/if}

            </td>

        </tr>

        <tr class='trbody' style="border-bottom: 1px solid #efefef">

            <td style='overflow:hidden;'><img src="{:tomedia($item['thumb'])}" style='width:50px;height:50px;border:1px solid #ccc; padding:1px;' onerror="this.src='../addons/ewei_shopv2/static/images/nopic.png'"></td>

            <td style='text-align: left;overflow:hidden;border-left:none;'>{$item['title']}</td>

            <td style='text-align:right;border-left:none;'>

                ¥ {if $item['is_team']==1}{$item['groupsprice']}{else}{$item['singleprice']}{/if}

                <br/>x1

            </td>

            <td  style='text-align: center;' >
                <a href="{:url('admin/member/list/etail',array('id'=>$item['mid']))}"> {$item['nickname']}</a>
                <br/>

                {$item['mrealname']}<br/>{$item['mmobile']}</td>

            <td style='text-align:center;' >

                {if $item['pay_type']=='wechat'}

                <span> <i class="icow icow-weixinzhifu text-success" style="font-size: 17px"></i>微信支付</span>

                {elseif $item['pay_type']=='credit'}

                <span> <i class="icow icow-yue text-warning" style="font-size: 17px;"></i><span>余额支付</span></span>

                {elseif $item['pay_type']=='alipay'}

                <span><i class="icow icow-zhifubaozhifu text-primary" style="font-size: 17px"></i>支付宝支付</span>

                {elseif $item['pay_type']=='other'}

                <span> <i class="text-info icow icow-icon" style="font-size: 17px"></i>其他</span>

                {elseif $item['pay_type']==''}

                <i class="icow icow-shibai text-danger"></i>未支付

                {/if}

                <br />

                <span style="margin-top:5px;display:block;">

                    {if $item['isverify'] == 1}

                    线下核销

                    {elseif !empty($item['addressid'])}

                    快递

                    {elseif !empty($item['isvirtualsend']) || !empty($item['virtual'])}

                    自动发货{if !empty($item['isvirtualsend'])}(虚拟物品){else}(虚拟卡密){/if}

                    {elseif $item['dispatchtype']}

                    自提

                    {else}

                    其他

                    {/if}

                </span>

                {if $item['refundtime']}

                <span class='label label-default'>已退款</span>

                {/if}

            </td>

            <td style='text-align:center' >

                ¥ {:number_format($item['price']-$item['creditmoney']+$item['freight'],2)}

                <a data-toggle='popover' data-html='true' data-trigger="hover" data-placement='right' data-content="<table style='width:100%;'>

                <tr>

                    <td  style='border:none;text-align:right;'>商品小计：</td>

                    <td  style='border:none;text-align:right;;'>

                        ¥ {:number_format($item['price'] + $item['discount'],2)}

                    </td>

                </tr>

                <tr>

                    <td  style='border:none;text-align:right;'>运费：</td>

                    <td  style='border:none;text-align:right;;'>¥ {:number_format( $item['freight'],2)}</td>

                </tr>

                {if $item['discount']>0}

                <tr>

                    <td  style='border:none;text-align:right;'>团长优惠：</td>

                    <td class='text-danger' style='border:none;text-align:right;'>- ¥{$item['discount']}</td>

                </tr>

                {/if}

                {if $item['discountprice']>0}

                <tr>

                    <td  style='border:none;text-align:right;'>会员折扣：</td>

                    <td  class='text-danger' style='border:none;text-align:right;;'>-¥ {:number_format( $item['discountprice'],2)}</td>

                </tr>

                {/if}

                {if $item['creditmoney']>0}

                <tr>

                    <td  style='border:none;text-align:right;'>积分抵扣：</td>

                    <td  class='text-danger' style='border:none;text-align:right;;'>-¥ {:number_format( $item['creditmoney'],2)}</td>

                </tr>

                {/if}

                {if $item['deductenough']>0}

                <tr>

                    <td  style='border:none;text-align:right;'>满额立减：</td>

                    <td  class='text-danger' style='border:none;text-align:right;;'>-¥ {:number_format( $item['deductenough'],2)}</td>

                </tr>

                {/if}

                {if $item['couponprice']>0}

                <tr>

                    <td  style='border:none;text-align:right;'>优惠券优惠：</td>

                    <td  class='text-danger' style='border:none;text-align:right;;'>-¥ {:number_format( $item['couponprice'],2)}</td>

                </tr>

                {if $item['isdiscountprice']>0}

                <tr>

                    <td  style='border:none;text-align:right;'>促销优惠：</td>

                    <td  class='text-danger' style='border:none;text-align:right;;'>-¥ {:number_format( $item['isdiscountprice'],2)}</td>

                </tr>

                {/if}

                {/if}

                {if intval($item['changeprice'])!=0}

                <tr>

                    <td  style='border:none;text-align:right;'>卖家改价：</td>

                    <td  style='border:none;text-align:right;;'>

                    <span class='{if 0<$item['changeprice']}success{else}danger{/if}'>

                    {if 0<$item['changeprice']}+{else}-{/if}¥ {:number_format(abs($item['changeprice']),2)}

                    </span>

                    </td>

                </tr>

                {/if}

                {if intval($item['changedispatchprice'])!=0}

                <tr>

                    <td  style='border:none;text-align:right;'>卖家改运费：</td>

                    <td  style='border:none;text-align:right;;'>

                        <span class='{if 0<$item['changedispatchprice']}success{else}danger{/if}'>

                        {if 0<$item['changedispatchprice']}+{else}-{/if}¥ {:abs($item['changedispatchprice'])}

                        </span>

                    </td>

                </tr>

                {/if}

                <tr>

                    <td style='border:none;text-align:right;'>应收款：</td>

                    <td style='border:none;text-align:right;font-weight:bold'>¥ {:number_format($item['price']-$item['creditmoney']+$item['freight'],2)}</td>

                </tr>

            </table>">

                    <i class='fa fa-question-circle'></i></a>

                {if $item['freight']>0}

                <br/>(含运费:¥ {:number_format( $item['freight'],2)})

                {/if}

            </td>

            <td style='text-align:center' >

                <a class='op text-primary'  href="{:url('admin/groups/verif/detail', array('orderid' => $item['id']))}" >查看详情</a>

                {if !empty($item['expresssn']) && $item['status']>=2 && !empty($item['addressid'])}

                <a class='op' data-toggle="ajaxModal" href="{:url('admin/utility/express', array('id' => $item['id'],'express'=>$item['express'],'expresssn'=>$item['expresssn']))}">查看物流</a>

                {/if}

            </td>

            <td  class='ops' style='line-height:20px;text-align:center' >

                {if $item['status'] == 0}<span class='text-danger'>待付款</span>{/if}

                {if $item['status'] == 1}<span class='text-navy'>已付款</span>{/if}

                {if $item['deleted'] == 1}

                <span class='text-default'>用户已删除</span>

                {else}

                {if $item['status'] == 3}<span class='text-success'>已完成</span>{/if}

                {if $item['status'] == -1}<span class='text-default'>已取消</span>{/if}

                {/if}

                <br />

                {if $item['isverify']==1 && $item['status'] == 1}

                <!--核销 确认核销-->
                <a class="btn btn-primary btn-xs" style="display: none;" data-toggle='ajaxPost' href="{:url('admin/groups/verifyfetch', array('id' => $item['id']))}" data-confirm="确认使用吗？">确认使用</a>

                {/if}

            </td>

        </tr>

        <!--<tr style="border-bottom:none;background:#f9f9f9;">-->

            <!--<td colspan='8' style='text-align:left;height:0;padding:0'></td>-->

        <!--</tr>-->

        {/foreach}

    </table>

    <div style="text-align:right;width:100%;">

        {$pager}

    </div>

    {else}

    <div class='panel panel-default'>

        <div class='panel-body' style='text-align: center;padding:30px;'>

            暂时没有任何订单!

        </div>

    </div>

    {/if}

</div>

</div>

{include file='_footer'}

